package com.fb4_messenger;

import java.util.ArrayList;
import java.util.Date;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseObject;

public class MainActivity extends Activity {

	public final static String userName = "com.fb4_messenger.USERNAME";
	private Activity context;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//Parse.initialize(this, "3F78tCV2BzyyeK8tNZO00rHbo5UJo7zO4LFVPRJx", "rOTervwR95Np4ljvPEofSAsn9LTrljtRjzeRmJLP");
		//ParseAnalytics.trackAppOpened(getIntent());
		 Parse.initialize(this, "4XyQ0lIo99HktsbMUoY4p29LhKKqHHlDq8F8pIvR", "xvBkygkNIOCJcHKMbW2VmktgazK4CG2p28CGlvcZ"); 
		//ParseObject testObject = new ParseObject("TestObject");
		//testObject.saveInBackground();
		context = this;
		 final ListView listview = (ListView) findViewById(R.id.listView1);
		    String[] values = new String[] { "Christoph", "Timo" };

		   final ArrayList<String> list = new ArrayList<String>();
		    for (int i = 0; i < values.length; ++i) {
		      list.add(values[i]);
		    }
		    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
		            android.R.layout.simple_list_item_1, list);
		        listview.setAdapter(adapter);
		        
		        listview.setClickable(true);
		        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

		          @Override
		          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		        	Intent intent = new Intent(context, DisplayMessageActivity.class);
		        	intent.putExtra("userName", "Christoph");
		        	
		        	
		            //Object o = listview.getItemAtPosition(position);

		            startActivity(intent);
		            finish(); 
		          }
		        });
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	

	@Override
	public void onDestroy() {
	    super.onDestroy();  // Always call the superclass
	    
	    // Stop method tracing that the activity started during onCreate()
	    android.os.Debug.stopMethodTracing();
	}
	

}
